package main

import "fmt"

// 结构体的匿名字段
type Person struct {
	string
	int
}

// 嵌套结构体
type Address struct {
	Province   string
	City       string
	UpdateTime string
}
type Email struct {
	Addr       string
	UpdateTime string
}
type People struct {
	Name   string
	Gender string
	Age    int
	Address
	Email
}

func main() {
	p1 := Person{
		"xinKong",
		18,
	}
	fmt.Println(p1)
	fmt.Println(p1.string)
	fmt.Println(p1.int)

	// 嵌套的结构体
	p2 := People{
		Name:   "XinKong",
		Gender: "男",
		Age:    18,
		Address: Address{
			Province:   "江苏",
			City:       "南通",
			UpdateTime: "2020-10-23",
		},
		Email: Email{
			Addr:       "address",
			UpdateTime: "2021-11-10",
		},
	}
	fmt.Printf("%#v\n", p2)
	fmt.Println(p2.Name, p2.Gender, p2.Age, p2.Address, p2.Email)
	//fmt.Println(p2.UpdateTime) 嵌套中包含多个同名的，直接访问不行
	fmt.Println(p2.Address.UpdateTime)
}
